﻿/**************************************************************
 *
 * 命名空间：Sgr.DataCategories.Domain.AdministrativeDivisions
 * 创建时间：2025/3/19
 * 描述：行政区划领域服务接口
 *
 **************************************************************/

using Sgr.Domain.Entities;
using Sgr.Domain.Managers;
using System.Threading;
using System.Threading.Tasks;

namespace Sgr.DataCategories.Domain.AdministrativeDivisions
{
    /// <summary>
    /// 行政区划领域服务接口
    /// </summary>
    public interface IAdministrativeDivisionManage : ITreeNodeManage<AdministrativeDivision, long>
    {
        /// <summary>
        /// 创建新的行政区划
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="code">代码</param>
        /// <param name="orderNumber">排序号</param>
        /// <param name="entityStates">状态</param>
        /// <param name="shortName">简称</param>
        /// <param name="pinyinName">拼音名称</param>
        /// <param name="pinyinAbbr">拼音缩写</param>
        /// <param name="description">描述</param>
        /// <param name="parentId">上级行政区划ID</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>行政区划领域对象</returns>
        Task<AdministrativeDivision> CreateNewAsync(
            string name,
            string code,
            int orderNumber,
            EntityStates entityStates,
            string? shortName = null,
            string? pinyinName = null,
            string? pinyinAbbr = null,
            string? description = null,
            long? parentId = null,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 检查行政区划代码是否唯一
        /// </summary>
        /// <param name="code">代码</param>
        /// <param name="excludeId">排除的ID</param>
        /// <param name="cancellationToken">取消令牌</param>
        /// <returns>是否唯一</returns>
        Task<DomainRuleCheckResult> ValidateCodeIsUniqueAsync(
            string code,
            long? excludeId = null,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 激活行政区划及其子行政区划
        /// </summary>
        /// <param name="administrativeDivision">行政区划</param>
        /// <param name="cancellationToken">取消令牌</param>
        Task ActivateAsync(AdministrativeDivision administrativeDivision, CancellationToken cancellationToken = default);

        /// <summary>
        /// 停用行政区划及其子行政区划
        /// </summary>
        /// <param name="administrativeDivision">行政区划</param>
        /// <param name="cancellationToken">取消令牌</param>
        Task DeactivateAsync(AdministrativeDivision administrativeDivision, CancellationToken cancellationToken = default);
    }
}